/*-----------------------------------------------------------------------------------
 *
 * 프로그램명	: CommonDAO.java
 * Version		: 1.0
 * 작성일 		: 2006-08-16
 * 작성자		:
 * 수정일 		:
 * 수정자		:
 * 설명		 	:
 * 기능		 	:
 *
 * Copyright (c) 2000 by H&H  All Rights Reserved.
 *
-------------------------------------------------------------------------------------*/
package com.zll.framework.db;

import java.io.*;
import java.util.*;
import java.sql.*;

public class MetaData
{
	public final static int ALIGN_LEFT = 0;
	public final static int ALIGN_CENTER = 1;
	public final static int ALIGN_RIGHT = 2;

	public final static int TYPE_STRING = 0;
	public final static int TYPE_INTEGER = 1;
	public final static int TYPE_DECIMAL = 2;
	public final static int TYPE_CLOB = 3;
	public final static int TYPE_ETC = 9;

	
	public String columnName = "";
	public String columnHeader = "";
	public int columnType = 0;
	public int precision = 0;
	public int scale = 0;
	public int align = 0;
	public boolean necessary = false;
	public String searchName = "";
	public String searchValue = "";
	
	public MetaData(String searchName, String searchValue) {
		this.searchName = searchName;
		this.searchValue = searchValue;
	}
	
	public MetaData(String columnName, int columnType, int precision, int scale, int isNullable) {
		this.columnName = columnName;		
		this.precision = precision;
		this.scale = scale;
		this.necessary = (isNullable == 0) ? true : false;
		
		setColumnType(columnType);
		
		//System.out.println("-------columnName:" + columnName + "  type:" + this.columnType + " precision:" + precision 
		//+ "  scale:"+ scale + "  isnull:" + isNullable);
	}
	
	
	private void setColumnType(int columnType) 
	{
		switch (columnType) 
		{
			case java.sql.Types.VARCHAR 	:
			case java.sql.Types.DATE		:
			case java.sql.Types.CHAR		:
			case java.sql.Types.TIMESTAMP 	: this.columnType = MetaData.TYPE_STRING;	break;
			
			case java.sql.Types.FLOAT		:
			case java.sql.Types.DOUBLE		:
			case java.sql.Types.NUMERIC		: 
			case java.sql.Types.DECIMAL		: this.columnType = MetaData.TYPE_DECIMAL;	break;
			
			case java.sql.Types.SMALLINT	:
			case java.sql.Types.INTEGER		: this.columnType = MetaData.TYPE_INTEGER;	break;
			
			case java.sql.Types.CLOB		: this.columnType = MetaData.TYPE_CLOB;		break;
			
			default 						: this.columnType = MetaData.TYPE_ETC;
			
		}
	}
}
